﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;

/// <summary>
/// ReturnMsg 的摘要说明
/// </summary>
public class ReturnMsg
{
	public ReturnMsg()
	{
		//
		// TODO: 在此处添加构造函数逻辑
		//

	}

    private int _retcode = 0;
    private string _remark = "";
    private DataTable _dtdata = new DataTable();
    private string _data = "";
    private string _sjson = "";

    /// <summary>
    /// 返回码
    /// </summary>
    public int retcode
    {
        get { return _retcode; }
        set { _retcode = value; }
    }
    /// <summary>
    /// 返回码对应的中文说明
    /// </summary>
    public string remark
    {
        get { return _remark; }
        set { _remark = value; }
    }
    /// <summary>
    /// 需要的返回的table，会将table解析为对应的json串，需要判断是否为空值
    /// </summary>
    public DataTable retdatatable
    {
        get { return _dtdata; }
        set { _dtdata = value; }
    }
    /// <summary>
    /// 单独的返回json串
    /// </summary>
    public string retjson
    {
        get { return _sjson; }
        set { _sjson = value; }
    }
    /// <summary>
    /// 返回的数据，将返回结果汇总并解析成固定的JSON格式
    /// </summary>
    public string retdata
    {
        get
        {
            string srjson = "";
            if (retdatatable != null)
            {
                Common.JsonHepler jh = new Common.JsonHepler();
                srjson = jh.ToJson(retdatatable);
            }
            else if (retjson != "")
                srjson = retjson;
            else
                srjson = "{}";
            _data = "{ \"retcode\":" + retcode.ToString() + " ,\"remark\":\"" + remark + "\",\"data\":" + srjson + "}";
            return _data;
        }
        set { _data = value; }
    }
}